﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using System.Data.SqlClient;
/// <summary>
/// Summary description for CustomerBus
/// </summary>
public class CustomerBus
{
    public static List<string> CountryList()
    {
        List<string> cultureList = new List<string>();
        CultureInfo[] getCultureInfo = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
        foreach (CultureInfo getCulture in getCultureInfo)
        {
            RegionInfo getRegionInfo = new RegionInfo(getCulture.LCID);
            if (!(cultureList.Contains(getCulture.EnglishName)))
            {
                cultureList.Add(getRegionInfo.EnglishName);
            }
        }
        cultureList.Sort();
        return cultureList;
    }

    public static List<Customer> getListCustomers()
    {
        List<Customer> lstCustomers = new List<Customer>();
        SqlConnection cnn = DatabaseInteraction.getConnection();
        cnn.Open();
        SqlCommand command = new SqlCommand("Select top 20 CustomerID,CompanyName,ContactName,ContactTitle,Address,City,Country,Phone from Customers", cnn);
        SqlDataReader reader = command.ExecuteReader();
        while (reader.Read())
        {
            Customer c = new Customer()
            {
                CustomerID = reader.GetString(0),
                CompanyName = reader.GetString(1),
                ContactName = reader.GetString(2),
                ContactTitle = reader.GetString(3),
                Address = reader.GetString(4),
                City = reader.GetString(5),
                Country = reader.GetString(6),
                Phone = reader.GetString(7)
            };
            lstCustomers.Add(c);
        }

        return lstCustomers;
    }
}